/*
 * @Author: deng-chao
 * @Description: 缓存管理
 */
const constant = {
  USER_INFO: 'userInfo',
  TOKEN: "access_token",
  REFRESH_TOKEN: "refresh_token",
};


/*user_info ---- serve*/
const setUserInfo = (data) => { uni.setStorage({ key: constant.USER_INFO, data: data }); };
const getUserInfo = () => { return uni.getStorageSync(constant.USER_INFO) };
const removeUserInfo = () => { uni.removeStorage({ key: constant.USER_INFO }); };
/*user_info ---- end*/

/*access_token ---- serve*/
const setToken = (data) => { uni.setStorage({ key: constant.TOKEN, data: data }); };
const getToken = () => { return uni.getStorageSync(constant.TOKEN); };
const removeToken = () => { uni.removeStorage({ key: constant.TOKEN }); };
/*access_token ---- end*/


/*refresh_token ---- serve*/
const setRefreshToken = (data) => { uni.setStorage({ key: constant.REFRESH_TOKEN, data: data }); };
const getRefreshToken = () => { return uni.getStorageSync(constant.REFRESH_TOKEN); };
const removeRefreshToken = () => { uni.removeStorage({ key: constant.REFRESH_TOKEN }); };
/*refresh_token ---- end*/



module.exports = {
  setUserInfo, getUserInfo, removeUserInfo,
  setToken, getToken, removeToken,
  setRefreshToken, getRefreshToken, removeRefreshToken,
};
